package com.hm.ibsm.rpc;

import org.springframework.beans.factory.annotation.Autowired;

import com.hm.ibsm.manage.rpc.AuthServiceGrpc;
import com.hm.ibsm.manage.rpc.AuthServiceOuterClass.ClientUserId;
import com.hm.ibsm.manage.rpc.AuthServiceOuterClass.ClientUserInfo;
import com.hm.ibsm.manage.service.AuthService;

import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;
import net.devh.springboot.autoconfigure.grpc.server.GrpcService;

/**
 * @author shishun.wang
 * @date 2017年2月21日 下午3:46:36
 * @version 1.0
 * @describe
 */
@Slf4j
@GrpcService(RpcAuthServiceImpl.class)
public class RpcAuthServiceImpl extends AuthServiceGrpc.AuthServiceImplBase {

	@Autowired
	private AuthService authService;
	
	@Override
	public void loadCurrentUserId(ClientUserInfo request, StreamObserver<ClientUserId> responseObserver) {
		log.info("-----------server----------->" + request.toString());
		System.out.println(authService.loadUserMenus(null));
		ClientUserId clientUserId = ClientUserId.newBuilder().setUserId("nihao123").build();
		responseObserver.onNext(clientUserId);
		responseObserver.onCompleted();
	}

}
